﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

namespace WebShopData
{
    static class GalaxySale2014DB
    {
        public static string ConnectionString
        {
            get { return ConfigurationManager.ConnectionStrings["GalaxySale2014"].ToString(); }
        }

        public static SqlConnection GetConnection()
        {
            SqlConnection connection = new SqlConnection(ConnectionString);
            connection.Open();
            return connection;
        }

        /// <summary>
        /// Creates a dataAdapter with the SQL command
        /// </summary>
        /// <param name="command">A SQL command to be executed</param>
        /// <returns>Returns the datasetTable from the db</returns>
        public static DataSet GetDataSet(SqlCommand command)
        {
            var adapter = new SqlDataAdapter(command);
            var dataSet = new DataSet();
            adapter.Fill(dataSet);
            return dataSet;
        }
    }
}
